<%@ page language="java" import="java.util.*" contentType="text/html"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
request.setCharacterEncoding("UTF-8");
String htmlData = request.getParameter("content1") != null ? request.getParameter("content1") : "";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta charset="UTF-8" />
  <script type="text/javascript" src='<c:url value="/js/boot.js"></c:url>'></script>
	<script charset="utf-8" src='<c:url value="/js/jquery.min.js"></c:url>'></script>
	<script charset="utf-8" src='<c:url value="/pages/kindeditor/kindeditor.js"></c:url>'></script>
	<script charset="utf-8" src='<c:url value="/pages/kindeditor/lang/zh_CN.js"></c:url>'></script>
	<script type="text/javascript" src='<c:url value="/js/rqfCommon/rqfCommon.js"></c:url>'></script>
	<script charset="utf-8" src='<c:url value="/pages/kindeditor/plugins/code/prettify.js"></c:url>'></script>
	<script>
	KindEditor.ready(function(K) {
        var options = {
	        filterMode : true,
	        items : [
		         'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste',
		        'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
		        'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
		        'superscript', 'clearhtml', 'quickformat', '|', 'fullscreen', '/',
		        'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
		        'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 'multiimage',
		        'flash', 'media', 'insertfile', 'table', 'hr', 'emoticons', 'pagebreak',
		        'anchor', 'link', 'unlink' 
				],
				cssPath : '<c:url value="/pages/kindeditor/plugins/code/prettify.css"></c:url>',
				uploadJson :'<c:url value="/pages/kindeditor/jsp/upload_json.jsp"></c:url>',
				fileManagerJson : '<c:url value="/pages/kindeditor/jsp/file_manager_json.jsp"></c:url>',
				allowFileManager : false,
				filterMode : false,
				afterCreate : function() {
					var self = this;
					K.ctrl(document, 13, function() {
						self.sync();
						document.forms['example'].submit();
					});
					K.ctrl(self.edit.doc, 13, function() {
						self.sync();
						document.forms['example'].submit();
					});
				}
			};
		
		var editor = K.create('textarea[name="content1"]', options);
		prettyPrint();
		editor.readonly();
		var rootPath = '${rootPath}';
		var id = '${course_res_id}';
		$(function(){
			getData();
		})
		function htmlspecialchars(str) {
			str = str.replace("&", "&amp;");
			str = str.replace("<", "&lt;");
			str = str.replace(">", "&gt;");
			str = str.replace("\"", "&quot;");
			return str;
		}
		function getData(){
			var url = rootPath + "/source/sourceFormData/" + id;
			$.ajax({
				url:url,
				method:"post",
				dataType:"json",
				data:{},
				success:function(data){
					if(data){
						editor.html(data.content);
					}
				}
			});
		}
    });
	</script>
</head>	
<body>
	<textarea name ="content1" style = "width:100%;height:540px;" id="content1"  rows="60" cols="50" placeholder=""></textarea>
</body>
</html>
